﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KPIS.GERP.GFMS.MODEL;
using KPIS.GERP.GFMS.IBLL;
using KPIS.GERP.GFMS.IDAL;
using KPIS.GERP.GFMS.DALFactory;

// test only
using KPIS.GERP.GFMS.DAL;

namespace KPIS.GERP.GFMS.BLL
{
    public class B_ICM_PurchaseOrderContractCollateral : IBLL_ICM_PurchaseOrderContractCollateral
    {
        Common common = new Common();
        private static readonly IDAL_ICM_PurchaseOrderContractCollateral dal = DataAccess.Create_ICM_PurchaseOrderContractCollateral();

        public B_ICM_PurchaseOrderContractCollateral()
        {

        }

        public IList<M_ICM_PurchaseOrderContractCollateral> GetFull(string icm_po_seq, string icm_col_type_seq)
        {
            Nullable<int> nicm_po_seq = common.ConvertNullInt(icm_po_seq);
            Nullable<int> nicm_col_type_seq = common.ConvertNullInt(icm_col_type_seq);
            return dal.GetFull(nicm_po_seq, nicm_col_type_seq);
        }

        public IList<M_ICM_PurchaseOrderContractCollateral> GetList(string icm_po_seq, string icm_col_type_seq)
        {
            Nullable<int> nicm_po_seq = common.ConvertNullInt(icm_po_seq);
            Nullable<int> nicm_col_type_seq = common.ConvertNullInt(icm_col_type_seq);
            return dal.GetList(nicm_po_seq, nicm_col_type_seq);
        }

        public M_ICM_PurchaseOrderContractCollateral GetInfo(string seq)
        {
            int nSeq;
 
            if (seq == null)
                return null;

            if (common.IsNumeric(seq))
            {
                nSeq = int.Parse(seq);
                return dal.GetInfo(nSeq);
            }
            else
            {
                return null;
            }
        }

        //public string SelectRecentInsertedRoleSeq()
        //{
        //    return dal.SelectRecentInsertedRoleSeq();
        //}

        public string Insert(M_ICM_PurchaseOrderContractCollateral info)
        {
            try
            {
                return dal.Insert(info);
            }
            catch
            {
                throw;
            }
        }

        public void Update(M_ICM_PurchaseOrderContractCollateral info)
        {
            try
            {
                dal.Update(info);
            }
            catch
            {
                throw;
            }
        }

        public void Delete(string seq)
        {
            try
            {
                int nSeq;

                if (seq == null)
                    return;

                if (common.IsNumeric(seq))
                {
                    nSeq = int.Parse(seq);
                    dal.Delete(nSeq);
                }
                else
                {
                    return;
                }
            }
            catch
            {
                throw;
            }
        }
    }
}
